import {GET_MENU_LIST_REQUEST, GET_MENU_LIST_SUCCESS, GET_MENU_LIST_FAILURE} from '$actions/menuList'

const initState = {
    error: '',
    menuList: {},
    loading: false
}

export default function reducer(state=initState, action) {
    switch(action.type) {
        case GET_MENU_LIST_REQUEST:
        return {
            error: '',
            menuList: {},
            loading: true
        }

        case GET_MENU_LIST_SUCCESS:
        return {
            error: '',
            menuList: action.payload,
            loading: false
        }

        case GET_MENU_LIST_FAILURE:
        return {
            error: action.error,
            menuList: {},
            loading: false
        }

        default:
        return state
    }
}